import { GCellRenderer } from "../../../../../../com/mui/controls/GCellRenderer";
import { ObjCreate } from "../../../common/ObjCreate";
import { GlobalStyle } from "../../../../../common/global/GlobalStyle";
import { ImagesConst } from "../../../../resource/ImagesConst";
import { LoaderHelp } from "../../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../../resource/ResFileConst";
import { GlobalClass } from "../../../../../../com/mui/core/GlobalClass";
import { SDominionBattleSituation } from "../../../../../../Message/Public/SDominionBattleSituation";
import { DomWarConst } from "../../DomWarConst";
import { ClockManager } from "../../../../manager/ClockManager";
import { RemainTimeTool } from "../../../award/RemainTimeTool";
import { SecTimer } from "../../../../../../com/gengine/core/frame/SecTimer";
import { TimerType } from "../../../../../../com/gengine/core/frame/TimerType";
import { Language } from "../../../../../../extend/language/Language";
import { GTextFiled } from "../../../../../../com/mui/controls/GTextFiled";
type int = number;
//class SiegeInfoCellRender
    
    export  class SiegeInfoCellRender extends GCellRenderer
    {
        constructor()
        {
            super();
            return;
        }

        protected /* override */ configUI(): void
        {
            super.configUI();
            this._smallSwordBmp = new Object /* flash.display.Bitmap */();
            this._smallShieldBmp = new Object /* flash.display.Bitmap */();
            this._smallVSBmp = new Object /* flash.display.Bitmap */();
            this.addChild(this._smallSwordBmp);
            this.addChild(this._smallShieldBmp);
            this.addChild(this._smallVSBmp);
            this._smallSwordBmp.x = 20;
            this._smallSwordBmp.y = 8;
            this._serNameTxt1 = ObjCreate.createGTextField("", 40, 8, 120, 20, this, GlobalStyle.textFormat5);
            this._serNameTxt1.autoSize = "left";
            this._nationPowerTxt1 = ObjCreate.createGTextField("", 175, 8, 120, 20, this);
            this._nationPowerTxt1.autoSize = "left";
            this._smallVSBmp.x = 295;
            this._smallVSBmp.y = 9;
            this._smallShieldBmp.x = 355;
            this._smallShieldBmp.y = 5;
            this._serNameTxt2 = ObjCreate.createGTextField("", 375, 8, 120, 20, this, GlobalStyle.textFormat5);
            this._serNameTxt2.autoSize = "left";
            this._nationPowerTxt2 = ObjCreate.createGTextField("", 500, 8, 120, 20, this);
            this._nationPowerTxt2.autoSize = "left";
            this._timeTxt = ObjCreate.createGTextField("", 605, 8, 120, 20, this);
            this._timeTxt.autoSize = "left";
            this._resultTxt = ObjCreate.createGTextField("--", 712, 8, 120, 20, this);
            this._resultTxt.autoSize = "left";
            ObjCreate.createBg(0, 31, 792, 2, this, ImagesConst.SplitLine);
            LoaderHelp.addResCallBack(ResFileConst.dominionWarBeacon, this.onLoaded);
            return;
        }

        /* internal  */onLoaded(): void
        {
            this._isLoad = true;
            this._smallShieldBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.DomWarBea_shieldSmall);
            this._smallSwordBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.DomWarBea_swordSmall);
            this._smallVSBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.DomWarBea_VSimg);
            var loc1;
            this._smallVSBmp.scaleY = loc1 = 0.5;
            this._smallVSBmp.scaleX = loc1;
            return;
        }

        /* internal  */get info(): SDominionBattleSituation
        {
            return this._data as SDominionBattleSituation;
        }

        public /* override */ set data(arg1: Object)
        {
            if (arg1 == null) 
            {
                return;
            }
            super.data = arg1;
            if (this.info) 
            {
                this._serNameTxt1.text = DomWarConst.getSerNameByDomId(this.info.mainActId);
                this._nationPowerTxt1.text = this.info.actCombat.toString();
                this._nationPowerTxt2.text = this.info.defCombat.toString();
                this._serNameTxt2.text = DomWarConst.getSerNameByDomId(this.info.mainDefId);
                this._resultTxt.text = this.getRetText(this.info.result);
            }
            return;
        }

        public updateTime(): void
        {
            var loc1=NaN;
            if (this.info) 
            {
                loc1 = this.info.endTime.time - ClockManager.instance.nowDate.time;
                loc1 = loc1 / 1000;
                this._timeTxt.text = RemainTimeTool.getRemainTimeBySeconds(loc1);
            }
            return;
        }

        /* internal  */startTimer(): void
        {
            if (!this._secTimer) 
            {
                this._secTimer = new SecTimer(1);
                this._secTimer.addListener(TimerType.ENTERFRAME, this.onTimerRun);
            }
            this._secTimer.reset();
            this._secTimer.start();
            return;
        }

        /* internal  */onTimerRun(arg1: SecTimer): void
        {
            return;
        }

        /* internal  */stopTimer(): void
        {
            if (this._secTimer) 
            {
                this._secTimer.stop();
            }
            return;
        }

        /* internal  */getRetText(arg1: int): string
        {
            var loc1=arg1;
            switch (loc1) 
            {
                case 0:
                {
                    return this.NO_RESULTSTR;
                }
                case 1:
                {
                    return Language.getString(41670);
                }
                case 2:
                {
                    return Language.getString(41671);
                }
            }
            return "";
        }

        /* internal */ /* const */NO_RESULTSTR: string="——";

        /* internal */ /* var */_smallSwordBmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_smallShieldBmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_smallVSBmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_serNameTxt1: GTextFiled;

        /* internal */ /* var */_serNameTxt2: GTextFiled;

        /* internal */ /* var */_nationPowerTxt1: GTextFiled;

        /* internal */ /* var */_nationPowerTxt2: GTextFiled;

        /* internal */ /* var */_timeTxt: GTextFiled;

        /* internal */ /* var */_resultTxt: GTextFiled;

        /* internal */ /* var */_secTimer: SecTimer;

        /* internal */ /* var */_isLoad: Boolean;
    }
